import pandas as pd 
from mlxtend.preprocessing import TransationEncoder
from mlxtend.frequent_patterns import apriori, association_rules

df = pd.read_excel('D:/yyj2/餐厅数据.xlsx')
print(df.head)
#转换菜品数据格式
trsations = df['菜品'].str.split(',').to_list()

ts = TransationEncoder()
te_ary = ts.fit(trsations).transform(trsations)
df_enecoded = pd.DataFrame(te_ary, columns=ts.columns)

print(df_enecoded.head)